package com.cx.auth.controller;

import com.cx.auth.form.RegisterBody;
import com.cx.auth.service.UserLoginService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserLoginService userLoginService;

    @PostMapping("register")
    public R<?> register(@Valid @RequestBody RegisterBody registerBody)
    {
        userLoginService.register(registerBody);
        return R.ok();
    }

    @PostMapping("changePwd")
    public R<?> changePwd(@Valid @RequestBody RegisterBody registerBody)
    {
        userLoginService.changePwd(registerBody);
        return R.ok();
    }

    @GetMapping("/sendCode/{email}")
    public R<?> sendCode(@PathVariable("email")String email)
    {
        userLoginService.sendEmail(email);
        return R.ok();
    }
}
